﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;//Add Ref

namespace Day2
{
    public partial class SMSPage : PhoneApplicationPage
    {
        public SMSPage()
        {
            InitializeComponent();
			bntSentSMS.Click +=new System.Windows.RoutedEventHandler(bntSentSMS_Click);
        }

        private void bntBrowse_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.
			PhoneNumberChooserTask p = new PhoneNumberChooserTask();
			p.Completed +=new System.EventHandler<Microsoft.Phone.Tasks.PhoneNumberResult>(p_Completed);
        	p.Show();
		}

        private void p_Completed(object sender, Microsoft.Phone.Tasks.PhoneNumberResult e)
        {
        	// TODO: Add event handler implementation here.
			if(e.TaskResult == TaskResult.OK){
				txtPhoneNumber.Text = e.PhoneNumber;
			}
        }

        private void bntSentSMS_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.
			SmsComposeTask sms = new SmsComposeTask();
			sms.To = txtPhoneNumber.Text;
			sms.Body = txtSMSBody.Text;
			sms.Show();
        }
    }
}
